﻿<?php
/*
* Restore MySQL dump using PHP
* (c) 2006 Daniel15 + (c) 2009 Ibrahim + Toan + Liang
* Last Update: 15th Feb 2009
*
*/
include('./config.php');
require_once('./Database.class.php');
$db = new Database();
?>

<html>
<head>
	<title>Projet EDD</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
		setTimeout("history.back()",4000);
	</script>
	<link href="./css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Projet EDD</h1>

<?php
// Name of the file
$fileName = './sql/refresh.sql';
 
// Temporary variable, used to store current query
$tempLine = '';
// Read in entire file into an array
$lines = file($fileName);
/*print "<pre>";
print_r($lines);
print "</pre>";*/
// Loop through each line
foreach($lines as $line_num => $line) {
  // Only continue if it's not a comment or it's not an empty line
  if (substr($line, 0, 2) != '--' && $line != '') {
    // Add this line to the current segment
    $tempLine .= $line;
    // If it has a semicolon at the end, it's the end of the query
    if (substr(trim($line), -1, 1) == ';') {
      // Perform the query
      $db->requeteSQL($tempLine) or print('Error performing query \'<b>' . $tempLine . '</b>\': ' . mysql_error() . '<br /><br />');
      // Reset temp variable to empty
      $tempLine = '';
    }
  }
}

echo "<div class = 'warning'>Data warehouse has been refreshed. You will be directed to the main page in 5 secondes</div>";
//header('Location: ./schema_fonctionnel.html'); 
?>
<div id="footer">
	Projet développé par Kim Toan PHAM, Ibrahim ZEHHAF, Liang HONG
</div>
</body>
</html>